import jwt
from django.conf import settings

def token_duc(user):
    property={
        'id':user.id,
        'username':user.username
    }
    token=jwt.encode(payload=property,key=settings.SECRET_KEY,algorithm='HS256')
    return token

def pars_token(token):
    payload=jwt.decode(token,key=settings.SECRET_KEY,algorithms='[HS256]')
    return payload